**Author: David Phillips
**
**takes the raw extract
**turns it into a file that works with matching code (infutor_mathces_scc)

clear
use santaclara_ever_102021_merged.dta 

gen SSN_last4  = substr(SSN,-4,.)
drop SSN

rename First_Name_0 First_Name_
rename Last_Name_0 Last_Name_
drop First_Name_? Last_Name_? First_Name_?? Last_Name_??
rename Gender_0 Gender_
drop Gender_? Gender_??

rename DeceasedCD DeceasedCD_

forvalues x = 1(1)10 {
	rename fips_county`x' Fips_County_`x'
	rename city`x' City_`x'
	rename state`x' State_`x'
	rename zip`x' Zipcode_`x'
	rename effective_date`x' Effective_Date_`x'
	rename last_verif_date`x' Last_Verification_Address_`x'
}

save mergedlast4_scc_ever_112021.dta, replace
